package com.ndp.fb.fbagent.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ndp.fb.fbagent.service.TargetingSpecFBService;
import com.ndp.fb.model.fbagent.param.useraudience.TargetingSpecParam;
import com.restfb.Parameter;

import java.util.List;


/**
 * 获取用户定位
 * Created by infi on 2015/1/21.
 */
@Service
public class TargetingSpecFBServiceImpl extends AbstractFBagentService implements TargetingSpecFBService {

    @Override
    public void targetingSpecReachEstimate(TargetingSpecParam estimateParam) {
        List<Parameter> params = adapter(estimateParam);
        String uri = "/act_" + estimateParam.getFbAccountId() + "/reachestimate";
        makeGetRequest(uri, estimateParam.getAccessToken(), params.toArray(new Parameter[]{}));
    }


    @Override
    public String targetingOfferBid(TargetingSpecParam  param) {
        List<Parameter> params = adapter(param);
        String uri = "/act_" + param.getFbAccountId() + "/reachestimate";
        return  syncFetchObjectResult(uri,param.getAccessToken(),String.class,params.toArray(new Parameter[]{}));
    }
}
